package com.docmgmt.mvp.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 权限实体（v3.0新增）
 *
 * 权限点格式：resource:action
 * 示例：
 * - file:upload
 * - folder:create
 * - kb:manage
 * - user:delete
 *
 * 28个权限点详见04-数据库设计文档
 *
 * @TableName sys_permission
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_permission")
public class PermissionEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /** 权限代码（唯一标识，如file:upload） */
    @TableField("permission_code")
    private String permissionCode;

    /** 权限名称（如"上传文件"） */
    @TableField("permission_name")
    private String permissionName;

    /** 资源类型（file/folder/kb/user/role/ai等） */
    @TableField("resource_type")
    private String resourceType;

    /** 操作类型（create/read/update/delete/manage等） */
    @TableField("action_type")
    private String actionType;

    @TableField("description")
    private String description;

    /** 权限分组（文件管理/知识库/AI/系统管理） */
    @TableField("permission_group")
    private String permissionGroup;

    /** 是否为系统内置权限（不可删除） */
    @TableField("is_system")
    private Boolean system;

    @TableLogic
    @TableField("is_deleted")
    private Boolean deleted;

    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;
}
